//
//  LGLungFollowSendTaskCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/7/5.
//  新建随访计划 - 任务Cell

#import "LGLungFollowSendTaskCell.h"

@interface LGLungFollowSendTaskCell()

/**   */
@property (nonatomic , strong)UILabel *indexLabel;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UILabel *typeTitle;
/**   */
@property (nonatomic , strong)UILabel *typeLabel;
/**   */
@property (nonatomic , strong)UILabel *projectTitle;
/**   */
@property (nonatomic , strong)UILabel *projectLabel;
/**   */
@property (nonatomic , strong)UILabel *evaluateTitle;
/**   */
@property (nonatomic , strong)UILabel *evaluateLabel;
/**   */
@property (nonatomic , strong)UILabel *publicTitle;
/**   */
@property (nonatomic , strong)UILabel *publicLabel;
/**   */
@property (nonatomic , strong)UILabel *tipTitle;
/**   */
@property (nonatomic , strong)UILabel *tipLabel;
/**   */
@property (nonatomic , strong)UIView *lineView;

@end

@implementation LGLungFollowSendTaskCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.type = LGPositionTypeMiddle;
        [self createSubView];
    }
    return  self;
}

-(void)setIndex:(NSInteger)index{
    _index = index;
    self.indexLabel.text = [NSString stringWithFormat:@"第%ld次任务",index];
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.dateLabel.text = LGNSString(dataDic[@"task_date"]);
    NSArray *projectArray = dataDic[@"task_check"];
    NSString *project = @"";
    for (NSString *content in projectArray) {
        project = (project.length>0)?[NSString stringWithFormat:@"%@、%@",project,content]:content;
    }
    self.projectLabel.text = project;
    
    //评估量表
    NSArray *evaArray = dataDic[@"task_eva"];
    NSString *evaString = @"";
    for (NSString *content in evaArray) {
        evaString = (evaString.length>0)?[NSString stringWithFormat:@"%@、%@",evaString,content]:content;
    }
    self.evaluateLabel.text = evaString;
    self.evaluateTitle.hidden = (evaArray.count>0)?NO:YES;
    CGFloat evaTop = (evaArray.count>0)?viewPix(10):-36;
    [self.evaluateLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.evaluateTitle.mas_bottom).offset(evaTop);
    }];
    
    //宣教项目
    NSArray *preachArray = dataDic[@"task_preach"];
    NSString *preachString = @"";
    for (NSString *content in preachArray) {
        preachString = (preachString.length>0)?[NSString stringWithFormat:@"%@、%@",preachString,content]:content;
    }
    self.publicLabel.text = preachString;
    self.publicTitle.hidden = (preachArray.count>0)?NO:YES;
    CGFloat publicTop = (preachArray.count>0)?viewPix(10):-36;
    [self.publicLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.publicTitle.mas_bottom).offset(publicTop);
    }];
    
    //关键字
    NSString *tips = LGNSString(dataDic[@"tips"]);
    self.tipTitle.hidden = YES;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.indexLabel];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.projectTitle];
    [self.contentView addSubview:self.projectLabel];
    [self.contentView addSubview:self.evaluateTitle];
    [self.contentView addSubview:self.evaluateLabel];
    [self.contentView addSubview:self.publicTitle];
    [self.contentView addSubview:self.publicLabel];
    [self.contentView addSubview:self.tipTitle];
    [self.contentView addSubview:self.tipLabel];
    
    [self.indexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(12));
        make.left.equalTo(self.contentView).offset(viewPix(28));
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.indexLabel.mas_right).offset(viewPix(16));
        make.centerY.equalTo(self.indexLabel);
    }];
    [self.projectTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.indexLabel.mas_bottom).offset(viewPix(12));
        make.left.right.equalTo(self.lineView);
    }];
    [self.projectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.projectTitle.mas_bottom).offset(viewPix(10));
        make.left.right.equalTo(self.lineView);
    }];
    [self.evaluateTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.projectLabel.mas_bottom).offset(viewPix(16));
        make.left.right.equalTo(self.lineView);
    }];
    [self.evaluateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.evaluateTitle.mas_bottom).offset(viewPix(10));
        make.left.right.equalTo(self.lineView);
    }];
    [self.publicTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.evaluateLabel.mas_bottom).offset(viewPix(16));
        make.left.right.equalTo(self.lineView);
    }];
    [self.publicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.publicTitle.mas_bottom).offset(viewPix(10));
        make.left.right.equalTo(self.lineView);
        make.bottom.equalTo(self.contentView).offset(-viewPix(12));
    }];
    [self.tipTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.publicLabel.mas_bottom).offset(viewPix(16));
        make.left.right.equalTo(self.lineView);
    }];
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tipTitle.mas_bottom).offset(viewPix(10));
        make.left.right.equalTo(self.lineView);
//        make.bottom.equalTo(self.contentView).offset(-viewPix(12));
    }];
    
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(28), 0, Screen_W-viewPix(56), 0.5)];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E8E8E8"];
    }
    return _lineView;
}

-(UILabel *)indexLabel{
    if(!_indexLabel){
        _indexLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _indexLabel;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _dateLabel;
}

-(UILabel *)projectTitle{
    if(!_projectTitle){
        _projectTitle = [UILabel lableWithText:@"随访项目" colorString:@"#909399" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _projectTitle;
}

-(UILabel *)projectLabel{
    if(!_projectLabel){
        _projectLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _projectLabel;
}

-(UILabel *)evaluateTitle{
    if(!_evaluateTitle){
        _evaluateTitle = [UILabel lableWithText:@"评估量表" colorString:@"#909399" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _evaluateTitle;
}

-(UILabel *)evaluateLabel{
    if(!_evaluateLabel){
        _evaluateLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _evaluateLabel;
}

-(UILabel *)publicTitle{
    if(!_publicTitle){
        _publicTitle = [UILabel lableWithText:@"宣教项目" colorString:@"#909399" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _publicTitle;
}

-(UILabel *)publicLabel{
    if(!_publicLabel){
        _publicLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _publicLabel;
}

-(UILabel *)tipTitle{
    if(!_tipTitle){
        _tipTitle = [UILabel lableWithText:@"关键字" colorString:@"#909399" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _tipTitle;
}

-(UILabel *)tipLabel{
    if(!_tipLabel){
        _tipLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _tipLabel;
}


@end
